package com.wz.receiver;

import com.wz.activity.SendMesgActivity;
import com.wz.util.ToastUtil;

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

public class SendBroadcastReceiver extends BroadcastReceiver {

	@Override
	public void onReceive(Context context, Intent intent) {

		SendMesgActivity.mmesgSendCount++;

		if (this.getResultCode() == android.app.Activity.RESULT_OK) {
			ToastUtil.showShort(context, "短信发送成功" + SendMesgActivity.mmesgSendCount + "/" + SendMesgActivity.mtotalCount);
			Log.d("Tag", "短信发送成功" + SendMesgActivity.mmesgSendCount + "/" + SendMesgActivity.mtotalCount);
		} else {
			ToastUtil.showShort(context, "短信发送失败" + SendMesgActivity.mmesgSendCount + "/" + SendMesgActivity.mtotalCount);
			Log.d("Tag", "短信发送失败" + SendMesgActivity.mmesgSendCount + "/" + SendMesgActivity.mtotalCount);
		}

		if (SendMesgActivity.mmesgSendCount == SendMesgActivity.mtotalCount) {
		    //因为在SendMesgActivity类中使用的是static 类型的数据,
			//所以短信发送结束后恢复数据默认值
			//否则会记录原来选择的数据
			 SendMesgActivity.clearContacts();
			
			((Activity)context).finish();
			Log.d("Tag","发送结束");
		}

	}
}
